<h2>DESCRIPTION</h2>
<p>The program <em>r.random</em> allows the user to create a
raster map layer and/or a vector points map containing 
coordinates of points whose locations have been randomly
determined.  The program locates these randomly generated
vector points (sites) within the current geographic region and mask (if
any), on non-NULL category value data areas within a
user-specified raster map layer. If the user sets the
<b>-z</b> flag, points will be randomly generated across all
cells (even those with NULL values).

<p>The category values and
corresponding category names already associated with the
random point locations in the <em>input</em> map layer are
assigned to these points in the <em>raster_output</em> map
layer. If the <b>-z</b> is specified, then a unique entry
is made for the value used where the <em>input</em> was NULL.
This value is at least 1 less than the smallest value in the
<em>input</em> raster and is given a medium gray color.

<h2>NOTES</h2>
<p>If a <em>cover</em> raster map is specified and the <em>cover</em> map
contains NULL (no data) values, these points are suppressed in the
resulting <em>vector_output</em> or <em>raster_output</em> map.

<p>The <em>vector_output</em> file created by <em>r.random</em>
contains vector points that represent the <em>center points</em> of the
randomly generated cells.  A <em>value</em> attribute contains the cell value
of the <em>input</em> raster (or the assigned value
when <b>-z</b> is used). <br>
If a <em>cover</em> map is additionally specified, a second
column  <em>covervalue</em> is populated with raster values from
the <em>cover</em> map.

<p>If the user sets the <b>-b</b> flag, vector points are written without
topology to minimize the required resources. This is suitable input
to <em>v.surf.rst</em> and other vector modules.

<p>The user may specify the quantity of random locations to be
generated either as a <em>positive integer</em> (e.g., 10),
or as a <em>percentage of the raster map layer's cells</em> 
(e.g., 10%, or 3.05%).  The number of cells considered for 
the percentage reflects whether or not the <b>-z</b> flag
was given. Options are 0-100; percentages less than
one percent may be stated as decimals.

<p>Flag <b>-i</b> prints the raster map's name and location, 
the total number of cells under the current region settings, and
the number of NULL valued cells under the current region settings.
Then module exits without doing anything.  Useful for deciding on the number
of sites to have <em>r.random</em> create.
<b>WARNING:</b> this feature may be removed in future. Use 
<a href="g.region.html">g.region</a> and 
<a href="r.report.html">r.report</a>
instead.
<div class="code"><pre>
g.region -p
r.report map=inputmap units=c null="*" nsteps=1
</pre></div>

<p>To create random vector point locations within some, but not all, 
non-zero categories of the input raster map layer, 
the user must first create a reclassified raster map layer 
of the original raster map layer (e.g., using the GRASS 
program <em><a href="r.reclass.html">r.reclass</a></em>) 
that contains only the desired categories, 
and then use the reclassed raster map layer as input to <em>r.random</em>.

<h2>EXAMPLES</h2>

<h3>Random 2D vector elevation points</h3>

Random vector elevation points sampled from elevation map in the
North Carolina sample dataset region, result stored in 2D vector map:

<div class="code"><pre>
g.region raster=elevation -p
r.random elevation vector=elevrand n=100
v.db.select elevrand
v.univar elevrand col=value type=point
</pre></div>

<h3>Random 3D vector elevation points</h3>

Random vector elevation points sampled from elevation map in the
North Carolina sample dataset region with collocated values sampled from
landuse map, result stored in 3D vector map:

<div class="code"><pre>
g.region raster=elevation -p
r.random -d elevation cover=landclass96 vector=luserand3d n=100

# data output (value: elevation, covervalue: landuse class):
v.db.select luserand3d
cat|value|covervalue
1|111.229591|5
2|71.093758|1
3|122.51075|5
4|146.17395|4
...
</pre></div>

<h2>KNOWN ISSUES</h2>

It's not possible to use the <b>-i</b> flag without specifying the
<b>npoints</b> parameter.


<h2>SEE ALSO</h2>

<em>
<a href="g.region.html">g.region</a>,
<a href="r.reclass.html">r.reclass</a>,
<a href="v.random.html">v.random</a>,
<a href="v.surf.rst.html">v.surf.rst</a>
</em>


<h2>AUTHOR</h2>

Dr. James Hinthorne,
GIS Laboratory, 
Central Washington University
<p>Modified for GRASS 5.0 by Eric G. Miller
<p>Cover map support by Markus Neteler, 2007

<!--
<p>
<i>Last changed: $Date$</i>
-->
